package com.itheima.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/requestTest01")
public class requestTest01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String contextPath = req.getContextPath();
        System.out.println("虚拟目录"+contextPath);
        String servletPath = req.getServletPath();
        System.out.println("映射路径"+servletPath);
        String remoteAddr = req.getRemoteAddr();
        System.out.println("访问者ip"+remoteAddr);
        String requestURI = req.getRequestURI();
        System.out.println("统一资源标识符"+requestURI);
        StringBuffer requestURL = req.getRequestURL();
        System.out.println("统一资源定位符"+requestURL);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
